using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Parallax : MonoBehaviour
{
    public Transform Cam;
    public float moveRate;

    private float startPointX, startPonitY;

    public bool lockY;
    // Start is called before the first frame update
    void Start()
    {
      startPointX = transform.position.x;
      startPonitY = transform.position.y;
        
    }

    // Update is called once per frame
    void Update()
    {
      float y = transform.position.y;
      if(!lockY){
        y = startPonitY-Cam.position.y * moveRate * 0.3f;
      }
      transform.position = new Vector2(startPointX+Cam.position.x*moveRate,y);
    }
}
